package com.company.poj;

import java.util.HashMap;
import java.util.Scanner;

/**
 * Created by v on 17-4-24.
 */
public class PojTest2503 {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        HashMap map=new HashMap();

        String line=input.nextLine();
        while (!line.equals("")){
            Scanner in=new Scanner(line);
            String a=in.next();
            String b=in.next();
            map.put(b,a);
            line=input.nextLine();
        }

        line=input.nextLine();
        while (!line.equals("")){
            if(!map.containsKey(line)){
                System.out.println("eh");
            }else {
                System.out.println(map.get(line));
            }
            line=input.nextLine();
        }
    }
}
